
package com.ternnetwork.core.notice.entity;


import com.ternnetwork.core.accesscontroll.entity.User;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Data
@Entity
@Table(name="AVO_NOTICE_READ_LOG")
public class NoticeReadLog implements Serializable{

	
 @EmbeddedId
 @AttributeOverrides( {
 @AttributeOverride(name="userId", column=@Column(name="USER_ID", nullable=false) ), 
 @AttributeOverride(name="noticeId", column=@Column(name="NOTICE_ID", nullable=false) ) } )
 private NoticeReadLogId id;
	
 @ManyToOne(fetch=FetchType.EAGER)
 @JoinColumn(name="USER_ID", nullable=false, insertable=false, updatable=false)
 private User user;
 
 @ManyToOne(fetch=FetchType.EAGER)
 @JoinColumn(name="NOTICE_ID", nullable=false, insertable=false, updatable=false)
 private Notice notice;

 @Temporal(TemporalType.TIMESTAMP)@Column(nullable=false,name="CREATE_TIME")
 private Date createTime=new Date();


@Override
public int hashCode() {
	final int prime = 31;
	int result = 1;
	result = prime * result + ((id == null) ? 0 : id.hashCode());
	return result;
}
@Override
public boolean equals(Object obj) {
	if (this == obj) {
		return true;
		
	}
	if (obj == null) {
		return false;
	}
	if (getClass() != obj.getClass()) {
		return false;
	}
	NoticeReadLog other = (NoticeReadLog) obj;
	if (id == null) {
		if (other.id != null) {
			return false;
		}
	} else if (!id.equals(other.id)) {
		return false;
	}
	return true;
}
 
 
}
